home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / src / autoload.c next >
C/C++ Source or Header  |  1992-10-09  |  1KB  |  43 lines

  1. #include "scheme.h"
  2.  
  3. Object V_Autoload_Notifyp;
  4.  
  5. Init_Auto () {
  6.     Define_Variable (&V_Autoload_Notifyp, "autoload-notify?", True);
  7. }
  8.  
  9. Object P_Autoload (sym, files) Object sym, files; {
  10.     Object al, ret;
  11.     GC_Node3;
  12.  
  13.     al = Null;
  14.     Check_Type (sym, T_Symbol);
  15.     Check_Loadarg (files);
  16.     GC_Link3 (al, sym, files);
  17.     al = Alloc_Object (sizeof (struct S_Autoload), T_Autoload, 0);
  18.     AUTOLOAD(al)->files = files;
  19.     AUTOLOAD(al)->env = The_Environment;
  20.     al = Cons (al, Null);
  21.     al = Cons (sym, al);
  22.     ret = P_Define (al);
  23.     GC_Unlink;
  24.     return ret;
  25. }
  26.  
  27. Object Do_Autoload (sym, al) Object sym, al; {
  28.     Object val, a[1];
  29.     GC_Node;
  30.  
  31.     if (Truep (Var_Get (V_Autoload_Notifyp))) {
  32.     a[0] = AUTOLOAD(al)->files;
  33.     Format (Standard_Output_Port, "[Autoloading ~s]~%", 18, 1, a);
  34.     }
  35.     GC_Link (sym);
  36.     (void)General_Load (AUTOLOAD(al)->files, AUTOLOAD(al)->env);
  37.     GC_Unlink;
  38.     val = SYMBOL(sym)->value;
  39.     if (TYPE(val) == T_Autoload)
  40.     Primitive_Error ("autoloading failed to define ~s", sym);
  41.     return val;
  42. }
  43.